package thread.kasir;

public class Kasir implements Runnable {
	
	private NumberGenerator generator;
	
	public Kasir(NumberGenerator generator){
		super();
		this.generator = generator;
	}
	@Override
	public void run() {
		//System.out.println("Mulai " + Thread.currentThread().getName());
		for (int i = 0; i < 10  ; i++) {
			BikinKuitansi();
			//System.out.println("Looping " + Thread.currentThread().getName());
		}
		//System.out.println("Selesai " + Thread.currentThread().getName());
	}
	


	public void BikinKuitansi(){
		synchronized (generator) {
			System.out.println(Thread.currentThread().getName() + " : " + generator.generate());
		}
		
		
	}
}
